﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace FirmaTransportowa
{
    public partial class StatisticsDriverStatisticsForm : Form
    {
        private StatisticsPanelPresenter presenter;

        public StatisticsDriverStatisticsForm(StatisticsPanelPresenter presenter)
        {
            InitializeComponent();
            this.presenter = presenter;
        }

        private void showButton_Click(object sender, EventArgs e)
        {
            List<String> names = new List<String>();
            List<String> surnames = new List<String>();

            chart1.Series.Clear();

            foreach (Object ob in driversListBox.SelectedItems)
            {
                String tmpText = ob.ToString();
                String name = null, surname = null;

                int point = tmpText.IndexOf(" ");

                name = tmpText.Substring(0, point);
                surname = tmpText.Substring(point + 1);

                names.Add(name);
                surnames.Add(surname);
                chart1.Series.Add(ob.ToString());
            }

            for (int i = 0; i < names.Count; i++)
            {
               chart1.Series[i].Points.Add(Transport.getDriverKm(names[i], surnames[i], startDateTimePicker.Value, endDateTimePicker.Value));
            }



        }

        private void StatisticsDriverStatisticsForm_Load(object sender, EventArgs e)
        {
            HelpUtils.showHelp(this, 27);
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.F1)
            {
                HelpUtils.showHelp(this, 27);
                return true;
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }
    }
}
